<include file="Public:header" />
<script type="text/javascript" charset="UTF-8" src="__PUBLIC__/Operation/js/my97date/wdatepicker.js"></script>
<div class="headbar">
    <div class="position"><span>促销</span><span>></span><span>优惠券</span><span>></span><span><if condition="$couponRow.id neq null">编辑<else/>添加</if>优惠券</span></div>
</div>

<div class="content_box">
    <div class="content form_content">
        <form action="{:U('Game/coupon_edit_act')}" method="post" name="couponForm" enctype='multipart/form-data'>
            <input name="id" value="" type="hidden" />

            <table class="form_table">
                <colgroup>
                    <col width="150px" />
                    <col />
                </colgroup>

                <tbody>
                    <tr>
                        <th>优惠券名称：</th>
                        <td><input class="normal" name="title" type="text" value="" pattern="required" alt="优惠券名称不能为空" /><label>* 优惠券名称（必填）</label></td>
                    </tr>
                    <tr>
                        <th>面值：</th><td><input class="small" name="value" value="" pattern="float" alt="面值不能为空"/><label>*</label></td>
                    </tr>
                    <tr>
                        <th>发放总量：</th>
                        <td><input class="small" name="total" type="text" value="" pattern="int" /><label>*</label></td>
                    </tr>
                    <tr>
                        <th>选择商品：</th>
                        <td>
                            <select class="auto" name="good_id" id="good_id" onchange="spceChange()">
                                <option value="">选择商品</option>
                                <foreach name='goods' item='item'>
                                    <option value="{$item['id']}" spec='{$item.spec_array}'>{$item['name']}</option>
                                </foreach>
                            </select><label>不选择商品默认是所有商品都可以使用此优惠券</label>
                        </td>
                    </tr>
                    <tr>
                        <th>生效时间：</th>
                        <td>
                            <input type='text' name='start_time' class='Wdate' pattern='datetime' onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" alt='请填写一个日期' value=""/>
                        </td>
                    </tr>
                    <tr>
                        <th>过期时间：</th>
                        <td>
                            <input type='text' name='end_time' class='Wdate' pattern='datetime' onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" alt='请填写一个日期' value="{$gameRow['end_time']}"/>
                        </td>
                    </tr>
                    <tr>
                        <th>过期天数：</th><td><input class="small" name="days_overdue" value=""/>天&nbsp;&nbsp;<label>*设置用户领取优惠券后多久过期</label></td>
                    </tr>
                    <tr>
                        <th>补充说明：</th>
                        <td>
                            <textarea class='textarea' name='description'></textarea>
                        </td>
                    </tr>
                    <tr>
                        <td></td><td><button class="submit" type="submit"><span>确 定</span></button></td>
                    </tr>
                </tbody>
            </table>
        </form>
    </div>
</div>

<script language="javascript">
    //DOM加载完毕
    $(function()
    {
        var couponRow = {$json_couponRow} ? {$json_couponRow} : '';
        if(couponRow){
            var formObj = new Form('couponForm');
            formObj.init(couponRow);
            
            //锁定字段一旦注册无法修改
            if($('[name="id"]').val())
            {
                var lockCols = ['total'];
                for(var index in lockCols)
                {
                    $('input:text[name="'+lockCols[index]+'"]').addClass('readonly');
                    $('input:text[name="'+lockCols[index]+'"]').attr('readonly',true);
                }
            }
        }
    });
</script>
<include file="Public:footer" />